namespace SupplierCustomerManagement.Read.API.Dtos
{
    public class ApiResponse<T>
    {
        public int code { get; set; } = 0;
        public string message { get; set; } = "OK";
        public T? data { get; set; }
        public bool success { get; set; } = true;

        public static ApiResponse<T> Ok(T data, string message = "OK") => new ApiResponse<T>
        {
            code = 0,
            message = message,
            data = data,
            success = true
        };

        public static ApiResponse<T> Fail(string message, int code = -1) => new ApiResponse<T>
        {
            code = code,
            message = message,
            data = default,
            success = false
        };
    }
}
